package server;

/**
 * @Author YWB
 * @Date 2021/1/18
 * desc HTTP协议处理工具类
 **/
public class HttpProtocolUtil {

    /**
     * 为响应码为200提供请求头信息
     * @param contentLength
     * @return
     */
    public static String getHttpHeader200(long contentLength){
        return "HTTP/1.1 200 OK \n"+"Content-Type:text/html \n"+"Content-Length: "+contentLength+"\n"+"\r\n";
    }

    public static String getHttpHeader404(){
        String str404="<h1>404 not found</h1>";
        return "HTTP/1.0 400 NOT Found \n"+"Content-Type:text/html \n"+"Content-Length: "+str404.getBytes().length+"\n"+"\r\n"+str404;
    }
}
